package com.twb.core.base.entity.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.twb.core.util.BeanUtils;

import cn.afterturn.easypoi.entity.BaseTypeConstants;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @ClassName TableHeader
 * @Description 表格头信息，用于Excel动态表头导出
 * @author DSY
 * @date 2022年7月29日 上午11:17:04
 */
@ApiModel("表格头信息，用于Excel动态表头导出")
public class TableHeader implements Serializable {

	private static final long serialVersionUID = 1L;

	public TableHeader() {

	}

	public TableHeader(String title) {
		this.title = title;
	}

	public TableHeader(String title, String field) {
		this.title = title;
		this.field = field;
	}

	public TableHeader(String title, String field, int width) {
		this.title = title;
		this.width = width;
		this.field = field;
	}

	/**
	 * @Title convertExcelExportEntity
	 * @Description 转成ExcelExportEntity
	 * @return
	 * @AuthorOriginally DSY
	 * @date 2022年7月29日 下午4:21:59
	 */
	public ExcelExportEntity convertExcelExportEntity() {
		if(this.ignore) {
			return null;
		}
		ExcelExportEntity excelExportEntity = new ExcelExportEntity();
		BeanUtils.copyNotNullProperties(this, excelExportEntity);
		excelExportEntity.setKey(this.field);
		excelExportEntity.setName(this.title);
		List<TableHeader> c = this.getChildren();
		if(null != c && !c.isEmpty()) {
			List<ExcelExportEntity> list = new ArrayList<ExcelExportEntity>();
			for (TableHeader t : c) {
				ExcelExportEntity e = t.convertExcelExportEntity();
				list.add(e);
			}
			excelExportEntity.setList(list);
		}
		return excelExportEntity;
	}
	/**
	 * 对应name
	 */
	@ApiModelProperty(name="title",value="列名",required=false)
	private String title;
	/**
	 * 对应type
	 */
	@ApiModelProperty(name="type",value="对应type",required=false)
	private int type = BaseTypeConstants.STRING_TYPE;
	/**
	 * 数据库格式
	 */
	@ApiModelProperty(name="databaseFormat",value="数据库格式",required=false)
	private String databaseFormat;
	/**
	 * 导出日期格式
	 */
	@ApiModelProperty(name="format",value="导出日期格式",required=false)
	private String format;
	/**
	 * 字典名称
	 */
	@ApiModelProperty(name="dict",value="字典名称",required=false)
	private String dict;
	/**
	 * 固定的列
	 */
	@ApiModelProperty(name="fixedIndex",value="固定的列",required=false)
	private Integer fixedIndex;
	/**
	 * 时区
	 */
	@ApiModelProperty(name="timezone",value="时区",required=false)
	private String timezone;
	/**
	 * 如果是MAP导出,这个是map的key
	 */
	@ApiModelProperty(name="field",value="列名标识",required=false)
	private String field;

	@ApiModelProperty(name="width",value="列宽",required=false)
	private double width = 10;

	@ApiModelProperty(name="height",value="列高",required=false)
	private double height = 10;

	/**
	 * 排序顺序
	 */
	@ApiModelProperty(name="orderNum",value="排序顺序",required=false)
	private int orderNum = 0;

	/**
	 * 是否支持换行
	 */
	@ApiModelProperty(name="isWrap",value="是否支持换行",required=false)
	private boolean isWrap;

	/**
	 * 是否需要合并
	 */
	@ApiModelProperty(name="needMerge",value="是否需要合并",required=false)
	private boolean needMerge;
	/**
	 * 单元格纵向合并
	 */
	@ApiModelProperty(name="mergeVertical",value="单元格纵向合并",required=false)
	private boolean mergeVertical;
	/**
	 * 合并依赖
	 */
	@ApiModelProperty(name="mergeRely",value="合并依赖",required=false)
	private int[] mergeRely;
	/**
	 * 后缀
	 */
	@ApiModelProperty(name="suffix",value="后缀",required=false)
	private String suffix;
	/**
	 * 统计
	 */
	@ApiModelProperty(name="isStatistics",value="统计",required=false)
	private boolean isStatistics;

	/**
	 * 数字格式
	 */
	@ApiModelProperty(name="numFormat",value="数字格式",required=false)
	private String numFormat;
	/**
	 * 是否隐藏列
	 */
	@ApiModelProperty(name="isColumnHidden",value="是否隐藏列",required=false)
	private boolean isColumnHidden;
	/**
	 * 脱敏规则
	 */
	@ApiModelProperty(name="desensitizationRule",value="脱敏规则",required=false)
	private String desensitizationRule;
	/**
	 * 是否忽略
	 */
	@ApiModelProperty(name="ignore",value="是否忽略，默认false",required=false)
	private boolean ignore = false;
	
	private List<TableHeader> children;

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getDatabaseFormat() {
		return databaseFormat;
	}

	public void setDatabaseFormat(String databaseFormat) {
		this.databaseFormat = databaseFormat;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getDict() {
		return dict;
	}

	public void setDict(String dict) {
		this.dict = dict;
	}

	public Integer getFixedIndex() {
		return fixedIndex;
	}

	public void setFixedIndex(Integer fixedIndex) {
		this.fixedIndex = fixedIndex;
	}

	public String getTimezone() {
		return timezone;
	}

	public void setTimezone(String timezone) {
		this.timezone = timezone;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

	public double getHeight() {
		return height;
	}

	public void setHeight(double height) {
		this.height = height;
	}

	public int getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(int orderNum) {
		this.orderNum = orderNum;
	}

	public boolean isWrap() {
		return isWrap;
	}

	public void setWrap(boolean isWrap) {
		this.isWrap = isWrap;
	}

	public boolean isNeedMerge() {
		return needMerge;
	}

	public void setNeedMerge(boolean needMerge) {
		this.needMerge = needMerge;
	}

	public boolean isMergeVertical() {
		return mergeVertical;
	}

	public void setMergeVertical(boolean mergeVertical) {
		this.mergeVertical = mergeVertical;
	}

	public int[] getMergeRely() {
		return mergeRely;
	}

	public void setMergeRely(int[] mergeRely) {
		this.mergeRely = mergeRely;
	}

	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public boolean isStatistics() {
		return isStatistics;
	}

	public void setStatistics(boolean isStatistics) {
		this.isStatistics = isStatistics;
	}

	public String getNumFormat() {
		return numFormat;
	}

	public void setNumFormat(String numFormat) {
		this.numFormat = numFormat;
	}

	public boolean isColumnHidden() {
		return isColumnHidden;
	}

	public void setColumnHidden(boolean isColumnHidden) {
		this.isColumnHidden = isColumnHidden;
	}

	public String getDesensitizationRule() {
		return desensitizationRule;
	}

	public void setDesensitizationRule(String desensitizationRule) {
		this.desensitizationRule = desensitizationRule;
	}

	public boolean isIgnore() {
		return ignore;
	}

	public void setIgnore(boolean ignore) {
		this.ignore = ignore;
	}

	public List<TableHeader> getChildren() {
		return children;
	}

	public void setChildren(List<TableHeader> children) {
		this.children = children;
	}
}
